package com.stoneframe.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.stoneframe.cache.CacheFactory;
import com.stoneframe.controller.base.BaseController;
import com.stoneframe.util.baseApp.AppHelper;
import com.stoneframe.util.baseApp.PageData;

@Controller
public class ClientDataController extends BaseController {
	
	private String className="ClientDataController.";
	
	@Resource(name="cacheFactory")
	private CacheFactory cacheFactory;
	
	@RequestMapping(value="get",produces="application/json;charset=UTF-8")
	@ResponseBody
	public Object get(){
		logBefore(logger, className+"get");
		try{
			Map<String,List<PageData>> map=new HashMap();
			map.put("dataItem",cacheFactory.getDataItemCache());
			map.put("organize",cacheFactory.getOrganizeCache());
			map.put("department",cacheFactory.getDepartmentCache());
			map.put("post",cacheFactory.getPostCache());
			map.put("role",cacheFactory.getRoleCache());
			
			logAfter(logger);
			return AppHelper.successObject(map);
		}catch(Exception e){
			logger.error(e.toString(), e);
			return AppHelper.errorObject(e.getMessage()); 
		}
	}
	

}
